<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('工程项目支付列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>项目编号：</label>
                                <input type="text" name="projectNo" autoComplete="off"/>
                            </li>
                            <li>
                                <label>项目名称：</label>
                                <input type="text" name="xmmc" autoComplete="off"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
<!--                 <a class="btn btn-primary single disabled" onclick="$.operate.editTab()" shiro:hasPermission="gcgl:fk:edit"> -->
<!--                     <i class="fa fa-edit"></i> 修改 -->
<!--                 </a> -->
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="gcgl:fk:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="gcgl:fk:export">
                    <i class="fa fa-download"></i> 导出
                </a>
<!--                 <a class="btn btn-success single disabled" onclick="fksqdprint()" > -->
<!--                     <i class="fa fa-download"></i> 打印付款申请单 -->
<!--                 </a> -->
<!--                 <a class="btn btn-success single disabled" onclick="addfklog()" shiro:hasPermission="gcgl:fklog:add"> -->
<!--                     <i class="fa fa-plus"></i> 付款 -->
<!--                 </a> -->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('gcgl:fk:edit')}]];
        var removeFlag = [[${@permission.hasPermi('gcgl:fk:remove')}]];
//         var datas = [[${@dict.getType('gcgl_project_fk_status')}]];
        
        var datas = [[${@dict.getType('sj_contract_status')}]];
        var xmtypedatas = [[${@dict.getType('gcgl_zf_type')}]];
        var prefix = ctx + "gcgl/fk";

        $(function() {
            var options = {
                url: prefix + "/list",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "款项支付",
                sortName: "id desc",
                sortOrder: "",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'gcProjectid',
                    title: '合同ID',
                    visible: false
                },
                {
                    field: 'projectId',
                    title: '管理子项目类型ID',
                    visible: false
                },
                {
                    field: 'xmtype',
                    title: '项目类型',
		            formatter: function(value, item, index) {
		            	return $.table.selectDictLabel(xmtypedatas, item.xmtype);
		            },
                    visible: false
		        },
                {
                    field: 'orderNo',
                    title: '付款编号',
                    visible: false
                },
                {
                    field: 'projectNo',
                    title: '项目编号'
                },
                {
                    field: 'xmmc',
                    title: '项目名称'
                },
                {
                    field: 'xmfzr',
                    title: '项目负责人'
                },
                {
                    field: 'htzje',
                    title: '合同总金额',
                    visible: false
                },
                {
                    field: 'ljzf',
                    title: '累计支付',
                    visible: false
                },
                {
                    field: 'xmmc',
                    title: '项目名称'
                },
                {
                    field: 'ckdw',
                    title: '单位名称'
                },
                {
                    field: 'nssbh',
                    title: '纳税识别号',
                    visible: false
                },
                {
                    field: 'riq',
                    title: '日期'
                },
                {
                    field: 'sqr',
                    title: '分管领导',
                    visible: false
                },
                {
                    field: 'sqrAt',
                    title: '分管领导审批时间',
                    visible: false
                },
                {
                    field: 'cwsh',
                    title: '财务审核',
                    visible: false
                },
                {
                    field: 'zjlsb',
                    title: '总经理批准',
                    visible: false
                },
                {
		            field: 'status',
		            title: '状态',
		            align: "left",
		            formatter: function(value, item, index) {
		            	return $.table.selectDictLabel(datas, item.status);
		            }
		        },
		        {
                    field: 'spyj',
                    title: '审批意见',
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        if(row.status==1){
                        	actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> ');
                        }else if(row.status==4){
                        	actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> ');
						}
                        actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="run(\'' + row.processInstanceId + '\')"><i class="fa fa-file-archive-o"></i>流程进度</a>&nbsp;');
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="fksqdprint(\'' + row.id + '\')"><i class="fa fa-edit"></i>查看</a> ');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        
        function addfklog(){
        	table.set();
        	var rows = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
            if (rows.length == 0) {
                $.modal.alertWarning("请至少选择一条记录");
                return;
            }
            
            if (rows.length > 1) {
                $.modal.alertWarning("请只选择一条记录");
                return;
            }
            
			var status = $.table.selectColumns("status");
            
            if(status==2){
            	$.modal.open('付款台账',"/gcgl/fklog/add/"+rows.join());
            }else{
            	$.modal.alertWarning("该记录未审核通过！");
                return;
            }
        }
        
        function fksqdprint(id){
//         	table.set();
//         	var rows = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
//             if (rows.length == 0) {
//                 $.modal.alertWarning("请至少选择一条记录");
//                 return;
//             }
            
//             if (rows.length > 1) {
//                 $.modal.alertWarning("请只选择一条记录");
//                 return;
//             }
            
            $.modal.openTab('查看',"/gcgl/fk/fksqdprint/"+id);
        }
        
        function run(processInstanceId) {
            $.modal.open("执行记录", ctx + "flow/monitor/historyDetail?processInstanceId=" + processInstanceId);
        }
        
        function traceProcess(processInstanceId) {
            $.modal.openTab("流程进度", ctx + "flow/monitor/traceProcess/"+processInstanceId);
        }
    </script>
</body>
</html>